package nodeanalysis;

import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

import com.netease.pris.input.CommonEditorInput;
import com.netease.pris.persist.BasePersist;
import com.netease.pris.server.Welcome;
import com.netease.pris.util.EditorUtil;

public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {

	public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
		super(configurer);
	}

	public ActionBarAdvisor createActionBarAdvisor(
			IActionBarConfigurer configurer) {
		return new ApplicationActionBarAdvisor(configurer);
	}

	public void preWindowOpen() {
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
		configurer.setInitialSize(new Point(400, 300));
		configurer.setShowCoolBar(true);
		configurer.setShowStatusLine(true);
		configurer.setTitle("Mercury Executor");
	}

	@Override
	public boolean preWindowShellClose() {
		BasePersist.getContainer().close();
		return super.preWindowShellClose();
	}

	@Override
	public void postWindowCreate() {
		super.postWindowCreate();
		getWindowConfigurer().getWindow().getShell().setMaximized(true);
		try {
			EditorUtil.openSingleEditor(getWindowConfigurer().getWindow().getActivePage(), new CommonEditorInput(), Welcome.ID);
		} catch (Exception e) {
		}
	}
	
	
}
